<!-- Copyright (c) 2019-2020 十三 all rights reserved. -->
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>料如指掌-注册</title>
    <link rel="stylesheet" th:href="@{/assets/css/common.css}">
    <link rel="stylesheet" th:href="@{/assets/css/login.css}">
    <link rel="stylesheet" th:href="@{/back/css/sweetalert2.min.css}"/>
    <link href="https://cdn.bootcdn.net/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
</head>
<body>
<div class="form center">
    <div class="login">
        <div class="login_center">
            <div class="login_top">
                <div class="left fl">会员注册</div>
                <div class="right fr"><a href="/login" target="_self">立即登录</a></div>
                <div class="clear"></div>
                <div class="under-line center"></div>
            </div>
            <form id="loginForm" th:action="@{/register}" method="post">
                <div class="login_main center">
                    <div class="login-info">用户名:&nbsp;<input class="login-info-input" type="text" name="username"
                                                             id="username"
                                                             placeholder="请输入你的用户名"/>
                    </div>
                    <div class="login-info">密&nbsp;&nbsp;&nbsp;&nbsp;码:&nbsp;<input class="login-info-input"
                                                                                    id="password"
                                                                                    type="password"
                                                                                    name="password"
                                                                                    placeholder="请输入你的密码"/></div>
                    <div class="login-info">确认&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<input class="login-info-input"
                                                                                    id="repassword"
                                                                                    type="password"
                                                                                    name="repassword"
                                                                                    placeholder="请再次输入你的密码"/></div>
                    <div class="login-info">邮箱&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<input class="login-info-input" type="email" name="email"
                                                             id="email"
                                                             placeholder="请输入你的邮箱"/>
                    </div>
                    <div class="login-info">手机号:&nbsp;<input class="login-info-input" type="text" name="tel_phone"
                                                             id="tel_phone"
                                                             placeholder="请输入你的手机号"/>
                    </div>
                </div>
                <div class="login_submit">
                    <input class="submit" type="button" value="确认" onclick="register()">
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<!-- jQuery -->
<script th:src="@{/assets/js/jquery.min.js}"></script>
<!--<script th:src="@{/admin/dist/js/public.js}"></script>-->
<script th:src="@{/back/css/sweetalert2.min.js}"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<script type="text/javascript">
    function register() {
        // var username = $("#username").val();
        // if (!validPhoneNumber(username)) {
        //     swal('请输入正确的登录名(即手机号)', {
        //         icon: "error",
        //     });
        //     return false;
        // }
        // var password = $("#password").val();
        // if (!validPassword(password)) {
        //     swal('请输入正确的密码格式(6-20位字符和数字组合)', {
        //         icon: "error",
        //     });
        //     return false;
        // }
        //验证
        var params = $("#loginForm").serialize();
        var url = '/register';
        $.ajax({
            type: 'POST',//方法类型
            url: url,
            data: params,
            dataType:'text',
            success: function (result) {
                if (result=='success') {
                    toastr.success("注册成功！")
                    // setTimeout(window.location.href = '/login',4000);
                } else if(result=='passwordFail'){
                    toastr.error("密码不一致！")
                }else{
                    toastr.error("注册失败！")
                }
            },
            error: function () {
                swal("操作失败", {
                    icon: "error",
                });
            }
        });
    }
</script>
</html>